<template>
  <span>
    {{ contentValue }}
  </span>
</template>

<script>
  import { mapGetters } from 'vuex'

  export default {
    name: 'DictListItem',
    props: {
      dictKey: {
        type: String,
        default: '',
        require: true,
      },
      dictVal: {
        type: [String, Number],
        default: '',
        require: true,
      },
    },
    computed: {
      ...mapGetters({
        certType: 'dict/certTypeJson',
        carColor: 'dict/carColorJson',
        carBrand: 'dict/carBrandJson',
        carType: 'dict/carTypeJson',
        countryList: 'dict/countryListJson',
        sexType: 'dict/sexTypeJson',
        nationList: 'dict/nationListJson',
        policyRole: 'dict/policyRoleJson',
        auditStatus: 'dict/auditStatusJson',
      }),
      contentValue() {
        if (!this.dictVal) {
          return '-'
        }
        if (this.dictKey === 'certType') {
          return this.certType[this.dictVal] || '-'
        } else if (this.dictKey === 'carColor') {
          return this.carColor[this.dictVal] || '-'
        } else if (this.dictKey === 'carBrand') {
          return this.carBrand[this.dictVal] || '-'
        } else if (this.dictKey === 'carType') {
          return this.carType[this.dictVal] || '-'
        } else if (this.dictKey === 'countryList') {
          return this.countryList[this.dictVal] || '-'
        } else if (this.dictKey === 'sexType') {
          return this.sexType[this.dictVal] || '-'
        } else if (this.dictKey === 'nationList') {
          return this.nationList[this.dictVal] || '-'
        } else if (this.dictKey === 'policyRole') {
          return this.policyRole[this.dictVal] || '-'
        } else if (this.dictKey === 'auditStatus') {
          return this.auditStatus[this.dictVal] || '-'
        } else {
          return '-'
        }
      },
      // eslint-disable-next-line vue/return-in-computed-property
      mounted() {
        console.log(`dict list item created ${this.dictKey}`)
        // return null
      },
    },
  }
</script>
